package com.orangelife.mobile.myhouse.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.curry.orangelife.mobile.R;
import com.orangelife.mobile.app.application.CurryApplication;
import com.orangelife.mobile.common.adapter.SimpleAdapter;
import com.orangelife.mobile.myhouse.biz.HouseBiz;
import com.orangelife.mobile.myhouse.biz.ViewTag;
import com.orangelife.mobile.myhouse.entity.IndustryBean;
import com.orangelife.mobile.myhouse.entity.IndustryEntity;
import com.orangelife.mobile.shoppingcart.biz.ShoppingCartBiz;

import java.util.List;

/**
 * Created by Administrator on 2015/12/3.
 */
public class CertOkRvAdapter2 extends SimpleAdapter<IndustryEntity.ApartmentsBean> {


    public CertOkRvAdapter2(List<IndustryEntity.ApartmentsBean> data) {
        super(data);
    }

    @Override
    public RecyclerView.ViewHolder onCreateDataViewHolder(ViewGroup parent) {
        View itemView = LayoutInflater.from(CurryApplication.getInstance().getContext()).inflate(R.layout.item_rv_cert_ok2, parent, false);
        return new CertViewHolder(itemView);
    }

    @Override
    public void onBindDataViewHolder(RecyclerView.ViewHolder holder, int position) {
        CertViewHolder h = (CertViewHolder) holder;
        h.mText.setText(mData.get(position).getHouseInfo());
        setTypeImage(h.ivType, mData.get(position).getApartmentType());
    }

    private void setTypeImage(ImageView iv, String type) {
        if ("1".equals(type)) {
            iv.setImageResource(R.drawable.ic_park);
        } else
            iv.setImageResource(R.drawable.ic_apartment);
    }

    private static class CertViewHolder extends RecyclerView.ViewHolder {

        TextView mText;
        ImageView ivType;

        public CertViewHolder(View itemView) {
            super(itemView);
            mText = (TextView) itemView.findViewById(R.id.tvApartmentID);
            ivType = (ImageView) itemView.findViewById(R.id.ivType);
        }
    }


}
